package com.newford.util;

import java.util.Locale;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ChangeLang extends ActionSupport {
	
	private String language;
	
	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}


	@Override
	public String execute() throws Exception {

		System.out.println(this.language);
		String[] strings = this.getLanguage().split("_");
		Locale locale = new Locale(strings[0], strings[1]);
		
		ServletActionContext.getContext().setLocale(locale);
//		ActionContext.getContext().getApplication().put("lang", this.getLanguage());
		ActionContext.getContext().setLocale(Locale.US); 
		ActionContext.getContext().getSession().put("WW_TRANS_I18N_LOCALE", locale); 
		return "success";
	}
	
}
